# Loughney et al., "Tectonic influence on Cenozoic mammal richness and sedimentation history of the Basin and Range, western North America"
# Science Advances
# Cross-correlation analyses and output

# load files
macrostrat <- read.csv("macrostrat_June-2021.csv", header = TRUE, stringsAsFactors = FALSE)
macrostrat_nonfossil <- read.csv("macrostrat_nonfossil_June-2021.csv", header = TRUE, stringsAsFactors = FALSE)
fossils <- read.csv("fossiliferous_units_January-2021.csv", header = TRUE, stringsAsFactors = FALSE)
deformation <- read.csv("deformation_rates_January-2021.csv", header = TRUE, stringsAsFactors = FALSE)
area <- read.csv("area_change.csv", header = TRUE, stringsAsFactors = FALSE)

# calculate SAR of fossiliferous units of the Basin and Range
brfossilsar <- fossils$NB_SAR + fossils$CB_SAR + fossils$SB_SAR

# cross-correlation analyses
# ------------------------------------------------------------------------------------------------------------------------------
# BR
# species richness - deformation rates
> brrichdef <- ccf(rev(brAllRichness[,2]), rev(deformation$BR_rate))
> brrichdef

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.064 -0.032  0.011  0.036  0.068  0.093  0.139  0.163  0.230  0.278  0.349  0.384  0.464  0.513  0.587  0.535  0.554  0.515 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.488  0.456  0.434  0.403  0.386  0.369  0.364  0.376  0.378  0.365  0.341  0.317  0.305 

# species richness - area-change rates
> brricharea <- ccf(rev(brAllRichness[,2]), rev(area$BR_rate_change_sum))
> brricharea

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.081 0.094 0.109 0.128 0.145 0.177 0.232 0.282 0.333 0.392 0.458 0.512 0.557 0.598 0.641 0.724 0.723 0.718 0.681 0.636 0.595 
    6     7     8     9    10    11    12    13    14    15 
0.548 0.489 0.439 0.391 0.354 0.299 0.252 0.225 0.177 0.150 

# species richness - macrostrat SAR
> brrichmacsar <- ccf(rev(brAllRichness[,2]), rev(macrostrat$BR_SAR))
> brrichmacsar

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
 0.091  0.019  0.047  0.050  0.037  0.077  0.128  0.050  0.064  0.092  0.139  0.125  0.061  0.059  0.028  0.709  0.057  0.044 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.039  0.032  0.038  0.045  0.018  0.016  0.012  0.004  0.003 -0.002 -0.005 -0.006 -0.010 

# species richness - number of macrostrat packages
> brrichmacno <- ccf(rev(brAllRichness[,2]), rev(macrostrat$BR_number))
> brrichmacno

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.237 0.237 0.255 0.277 0.292 0.336 0.379 0.390 0.415 0.448 0.488 0.517 0.494 0.495 0.496 0.773 0.665 0.553 0.569 0.498 0.523 
    6     7     8     9    10    11    12    13    14    15 
0.378 0.330 0.302 0.267 0.220 0.219 0.172 0.136 0.145 0.100 

# species richness - fossiliferous unit SAR
> brrichfosssar <- ccf(rev(brAllRichness[,2]), rev(brfossilsar))
> brrichfosssar

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.324 0.358 0.381 0.395 0.422 0.440 0.465 0.470 0.485 0.503 0.512 0.513 0.513 0.532 0.560 0.626 0.498 0.461 0.435 0.469 0.460 
    6     7     8     9    10    11    12    13    14    15 
0.449 0.391 0.373 0.427 0.353 0.372 0.300 0.275 0.308 0.260 

# species richness - number of fossiliferous units
> brrichfossno <- ccf(rev(brAllRichness[,2]), rev(fossils$BR_number))
> brrichfossno

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.099 0.139 0.171 0.206 0.254 0.291 0.334 0.365 0.396 0.429 0.444 0.461 0.475 0.507 0.547 0.506 0.510 0.489 0.514 0.541 0.520 
    6     7     8     9    10    11    12    13    14    15 
0.545 0.497 0.494 0.481 0.437 0.460 0.408 0.397 0.429 0.373 

# species richness - number of fossil localities
> brrichlocs <- ccf(rev(brAllRichness[,2]), rev(brBinLocs[,2]))
> brrichlocs

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.095 0.055 0.106 0.149 0.174 0.236 0.299 0.277 0.311 0.354 0.417 0.426 0.382 0.409 0.402 0.958 0.367 0.341 0.304 0.298 0.263 
    6     7     8     9    10    11    12    13    14    15 
0.242 0.186 0.152 0.176 0.162 0.134 0.086 0.086 0.068 0.132 

# ----------------------------------------------------------------------------------------------------------------------------------
# NB
# species richness - deformation rates
> nbrichdef <- ccf(rev(nbAllRichness[,2]), rev(deformation$NB_def))
> nbrichdef

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.053 0.070 0.110 0.153 0.151 0.161 0.162 0.103 0.089 0.134 0.169 0.228 0.279 0.283 0.239 0.327 0.318 0.282 0.231 0.218 0.192 
    6     7     8     9    10    11    12    13    14    15 
0.148 0.129 0.193 0.261 0.116 0.109 0.143 0.096 0.051 0.092 

# species richness - area-change rates
> nbricharea <- ccf(rev(nbAllRichness[,2]), rev(area$NB_rate_change_sum))
> nbricharea

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
 0.119  0.131  0.146  0.159  0.158  0.162  0.167  0.189  0.219  0.247  0.280  0.304  0.313  0.297  0.298  0.262  0.247  0.235 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.225  0.193  0.187  0.175  0.169  0.166  0.149  0.133  0.078  0.039  0.021 -0.001  0.010 

# species richness - macrostrat SAR
> nbrichmacsar <- ccf(rev(nbAllRichness[,2]), rev(macrostrat$NB_SAR))
> nbrichmacsar

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.195 0.028 0.038 0.049 0.082 0.086 0.243 0.054 0.039 0.050 0.054 0.072 0.059 0.049 0.056 0.895 0.092 0.056 0.057 0.051 0.073 
    6     7     8     9    10    11    12    13    14    15 
0.048 0.053 0.067 0.068 0.036 0.035 0.032 0.010 0.028 0.025 

# species richness - number of macrostrat packages
> nbrichmacno <- ccf(rev(nbAllRichness[,2]), rev(macrostrat$NB_number))
> nbrichmacno

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.192 0.167 0.177 0.195 0.212 0.253 0.293 0.250 0.239 0.252 0.255 0.284 0.247 0.241 0.252 0.600 0.417 0.315 0.321 0.287 0.391 
    6     7     8     9    10    11    12    13    14    15 
0.192 0.199 0.214 0.207 0.183 0.194 0.176 0.118 0.142 0.105 

# species richness - fossiliferous unit SAR
> nbrichfosssar <- ccf(rev(nbAllRichness[,2]), rev(fossils$NB_SAR))
> nbrichfosssar

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.191 0.166 0.171 0.170 0.204 0.221 0.277 0.264 0.255 0.242 0.264 0.278 0.295 0.332 0.348 0.533 0.260 0.178 0.142 0.207 0.258 
    6     7     8     9    10    11    12    13    14    15 
0.271 0.282 0.264 0.255 0.172 0.161 0.151 0.160 0.233 0.224 

# species richness - number of fossiliferous units
> nbrichfossno <- ccf(rev(nbAllRichness[,2]), rev(fossils$NB_number))
> nbrichfossno

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.077 0.085 0.094 0.116 0.155 0.192 0.229 0.244 0.217 0.212 0.222 0.256 0.274 0.318 0.358 0.398 0.292 0.172 0.185 0.199 0.227 
    6     7     8     9    10    11    12    13    14    15 
0.220 0.241 0.221 0.232 0.155 0.132 0.112 0.139 0.188 0.167 

# species richness - number of fossil localities
> nbrichlocs <- ccf(rev(nbAllRichness[,2]), rev(nbBinLocs[,2]))
> nbrichlocs

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.207 0.045 0.046 0.050 0.082 0.069 0.221 0.077 0.088 0.060 0.031 0.048 0.034 0.039 0.063 0.956 0.073 0.030 0.023 0.043 0.030 
    6     7     8     9    10    11    12    13    14    15 
0.063 0.035 0.037 0.123 0.051 0.058 0.014 0.020 0.007 0.206 

# --------------------------------------------------------------------------------------------------------------------------------
# CB
# species richness - deformation rates
> cbrichdef <- ccf(rev(cbAllRichness[,2]), rev(deformation$CB_rate))
> cbrichdef

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.013  0.034  0.079  0.102  0.125  0.147  0.184  0.227  0.307  0.373  0.449  0.521  0.607  0.671  0.737  0.700  0.691  0.601 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.538  0.496  0.461  0.443  0.425  0.404  0.361  0.389  0.334  0.279  0.193  0.134  0.069 

# species richness - area-change rates
> cbricharea <- ccf(rev(cbAllRichness[,2]), rev(area$CB_rate_change_sum))
> cbricharea

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.142 0.151 0.167 0.186 0.202 0.220 0.233 0.252 0.279 0.332 0.391 0.443 0.488 0.525 0.564 0.618 0.639 0.645 0.634 0.612 0.596 
    6     7     8     9    10    11    12    13    14    15 
0.568 0.539 0.520 0.486 0.437 0.384 0.327 0.267 0.211 0.169 


# species richness - macrostrat SAR
> cbrichmacsar <- ccf(rev(cbAllRichness[,2]), rev(macrostrat$CB_SAR))
> cbrichmacsar

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
 0.064  0.048  0.032  0.010  0.066  0.043 -0.011 -0.047 -0.046  0.030  0.004 -0.002 -0.031 -0.045 -0.035  0.540  0.080  0.046 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.037  0.029  0.084  0.154  0.038  0.038  0.032  0.035  0.048  0.045  0.053  0.034  0.033 

# species richness - number of macrostrat packages
> cbrichmacno <- ccf(rev(cbAllRichness[,2]), rev(macrostrat$CB_number))
> cbrichmacno

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
 0.046  0.016 -0.013 -0.046 -0.039 -0.027 -0.032 -0.022 -0.020  0.017  0.048  0.063  0.090  0.114  0.168  0.432  0.450  0.376 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.474  0.441  0.487  0.484  0.423  0.419  0.425  0.433  0.447  0.398  0.397  0.357  0.314 

# species richness - fossiliferous unit SAR
> cbrichfosssar <- ccf(rev(cbAllRichness[,2]), rev(fossils$CB_SAR))
> cbrichfosssar

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.108 0.181 0.212 0.231 0.232 0.218 0.236 0.267 0.292 0.272 0.325 0.325 0.335 0.410 0.466 0.449 0.419 0.396 0.402 0.351 0.455 
    6     7     8     9    10    11    12    13    14    15 
0.466 0.337 0.345 0.581 0.340 0.441 0.383 0.346 0.282 0.198 

# species richness - number of fossiliferous units
> cbrichfossno <- ccf(rev(cbAllRichness[,2]), rev(fossils$CB_number))
> cbrichfossno

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.149 -0.096 -0.067 -0.038  0.004  0.031  0.081  0.127  0.176  0.200  0.269  0.305  0.352  0.426  0.465  0.513  0.486  0.498 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.511  0.502  0.575  0.614  0.545  0.586  0.643  0.508  0.574  0.497  0.451  0.391  0.294 

# species richness - number of fossil localities
> cbrichlocs <- ccf(rev(cbAllRichness[,2]), rev(cbBinLocs[,2]))
> cbrichlocs

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.065  0.018  0.135  0.239  0.365  0.431  0.467  0.475  0.499  0.516  0.510  0.509  0.541  0.609  0.675  0.879  0.619  0.532 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.428  0.358  0.287  0.214  0.167  0.128  0.116  0.148  0.113 -0.011 -0.047 -0.102 -0.155 
 
# -----------------------------------------------------------------------------------------------------------------------------
# SB
# species richness - deformation rates
> sbrichdef <- ccf(rev(sbAllRichness[,2]), rev(deformation$SB_rate))
> sbrichdef

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.195 -0.151 -0.149 -0.135 -0.118 -0.114 -0.100 -0.102 -0.090 -0.082 -0.084 -0.088 -0.063 -0.040 -0.012 -0.141 -0.126 -0.130 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
-0.088 -0.072 -0.052 -0.019  0.007  0.036  0.053  0.064  0.226  0.255  0.290  0.293  0.292 

# species richness - area-change rates
> sbricharea <- ccf(rev(sbAllRichness[,2]), rev(area$SB_rate_change_sum))
> sbricharea

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.092 -0.063 -0.050 -0.040 -0.031 -0.011  0.019  0.050  0.077  0.108  0.139  0.153  0.160  0.151  0.154  0.166  0.192  0.230 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.254  0.261  0.265  0.264  0.268  0.268  0.259  0.250  0.228  0.207  0.207  0.183  0.188 

# species richness - macrostrat SAR
> sbrichmacsar <- ccf(rev(sbAllRichness[,2]), rev(macrostrat$SB_SAR))
> sbrichmacsar

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.009  0.028  0.070  0.080 -0.022  0.068  0.039  0.075  0.105  0.110  0.205  0.167  0.088  0.099  0.044  0.790  0.006  0.006 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.006  0.004  0.001  0.001 -0.002 -0.003 -0.005 -0.008 -0.011 -0.014 -0.015 -0.013 -0.016 

# species richness - number of macrostrat packages
> sbrichmacno <- ccf(rev(sbAllRichness[,2]), rev(macrostrat$SB_number))
> sbrichmacno

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.022 -0.019  0.022  0.065  0.099  0.131  0.182  0.211  0.262  0.305  0.370  0.418  0.423  0.409  0.374  0.520  0.505  0.430 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.415  0.327  0.234  0.125  0.049  0.018 -0.047 -0.096 -0.097 -0.135 -0.124 -0.032 -0.044 

# species richness - fossiliferous unit SAR
> sbrichfosssar <- ccf(rev(sbAllRichness[,2]), rev(fossils$SB_SAR))
> sbrichfosssar

Autocorrelations of series ‘X’, by lag

  -15   -14   -13   -12   -11   -10    -9    -8    -7    -6    -5    -4    -3    -2    -1     0     1     2     3     4     5 
0.220 0.159 0.102 0.091 0.107 0.098 0.116 0.112 0.136 0.160 0.135 0.166 0.222 0.266 0.255 0.108 0.194 0.244 0.318 0.391 0.337 
    6     7     8     9    10    11    12    13    14    15 
0.434 0.324 0.300 0.205 0.433 0.439 0.241 0.228 0.250 0.144 

# species richness - number of fossiliferous units
> sbrichfossno <- ccf(rev(sbAllRichness[,2]), rev(fossils$SB_number))
> sbrichfossno

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
 0.013 -0.009 -0.025 -0.022  0.015  0.026  0.067  0.087  0.110  0.140  0.113  0.145  0.186  0.249  0.278  0.159  0.270  0.328 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.400  0.476  0.395  0.465  0.365  0.362  0.274  0.351  0.380  0.328  0.330  0.359  0.291 

# species richness - number of fossil localities
> sbrichlocs <- ccf(rev(sbAllRichness[,2]), rev(sbBinLocs[,2]))
> sbrichlocs

Autocorrelations of series ‘X’, by lag

   -15    -14    -13    -12    -11    -10     -9     -8     -7     -6     -5     -4     -3     -2     -1      0      1      2 
-0.002  0.021  0.054  0.054  0.010  0.087  0.064  0.108  0.153  0.186  0.272  0.259  0.241  0.346  0.390  0.923  0.354  0.345 
     3      4      5      6      7      8      9     10     11     12     13     14     15 
 0.272  0.253  0.243  0.242  0.161  0.095  0.069  0.078  0.016  0.075  0.095  0.050  0.043 